import createPersistedState from "vuex-persistedstate"
import Vue from "vue";
import Vuex from "vuex";
// 引入拆分出去的子模块
Vue.use(Vuex);
const files = require.context('./modules', false, /\.js$/)
const modules = {}
files.keys().forEach((key) => {
  modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
})
Object.keys(modules).forEach((key) => {
  modules[key]['namespaced'] = true
})
console.log("debug log --> ", modules)

export default new Vuex.Store({
  state: {},
  mutations: {},
  actions: {},
  modules,
  plugins: [createPersistedState({
    storage: window.sessionStorage
  })]

});

